package com.dms.service.impl;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dms.dao.BugDao;
import com.dms.entity.Bug;
import com.dms.service.BugService;
 

 
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Service("bugService")
public class BugServiceImpl implements BugService {

	@Autowired
	private BugDao bugDao;

	@Transactional(readOnly = true)
	@Override
	public List<Bug> findBug(Bug bug ) {
		 
		Map<String, Object> params = new HashMap<>();
		params.put("bug", bug);

	 
		List<Bug> bugs = bugDao.selectByPage(params);
		return bugs;
	}

	// 鏍规嵁bug_id鏌ヨ
	@Transactional(readOnly = true)
	@Override
	public Bug selectBugById(Integer bug_id) {

		return this.bugDao.selectBugsById(bug_id);
	}

	// 娣诲姞bug
	@Override
	public void addBug(Bug bug) {
		this.bugDao.addBug(bug);

	}

	// 鍒犻櫎bug
	@Override
	public void deleteBug(Integer bug_id) {
		this.bugDao.deletebug(bug_id);

	}

	// 淇敼bug
	@Override
	public void modifyBug(Bug bug) {
		this.bugDao.update(bug);

	}

	//娣诲姞鍚庨┈涓婃樉绀�
	@Transactional(readOnly = true)
	@Override
	public Bug selectBugByAdd(Bug bug) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<>();
		params.put("bug", bug);		
		return this.bugDao.selectBugByAdd(params);
	}

	@Transactional(readOnly = true)
	@Override
	public Integer countbug(Bug bug) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<>();
		params.put("bug", bug);
		return this.bugDao.count(params);
	}

 
	@Transactional(readOnly = true)
	@Override
	public List<Bug> selectBug(Bug bug) {
		Map<String, Object> params = new HashMap<>();
		params.put("bug", bug);
		return this.bugDao.selectByPage(params);		
	}
	

	@Override
	public List<Bug> selectBugByreporterId(Integer USER_id) {
		// TODO Auto-generated method stub
		return this.bugDao.selectBugByreporterId(USER_id);
	}

	@Override
	public List<Bug> selectBugByhandlerId(Integer handler_id) {
		// TODO Auto-generated method stub
		return this.bugDao.selectBugByhandlerId(handler_id);
	}

	@Override
	public List<Bug> selectAllBug() {
		// TODO Auto-generated method stub
		return this.bugDao.selectAllBug();
	}

	 

}
